#include "led.h"
#include "beep.h"
#include "systick.h"
#include "key.h"

static uint8_t key1=0;
static uint8_t key2=0;
static uint8_t key3=0;
int main(void)
        {
        	delay_init(168);
			beep_init();
			key1_init();
			key2_init();
			key3_init();
			led_init();
			led1_init();
			led2_init();
			led3_init();
            while(1)
            {
				if(key1_get())
				{
					key1=~key1;
					if(key1)
					{
						beep_open();
					}
					else
					{
						beep_off();
					}
				}
				if(key2_get())
				{
					key2=~key2;
					if(key2)
					{
						led_open();
					}
					else
					{
						led_off();
					}
				}
				if(key3_get())
				{
					key3=~key3;
					if(key3)
					{
						while(1)
						{
							led1_open();
							delay_ms(1000);
							led1_off();
							led2_open();
							delay_ms(1000);
							led2_off();
							led3_open();
							delay_ms(1000);
							led3_off();
							if(key3_get())
							{
								key3 = ~key3;
								if(!key3) break;
							}
						}
					}
					else
					{
						led1_off();
						led2_off();
						led3_off();
					}
				}
            }
        }
		